import { AnimateEvent } from '@leafer-in/animate'
import { IUI } from 'leafer-ui'

export const nextRender = (uiItem: IUI) => {
    return new Promise((resolve) => {
        uiItem.nextRender(resolve)
    })
}

type IAnimateParams = Parameters<IUI['animate']>

export const leaferAnime = (uiItem: IUI, ...rest: IAnimateParams) => {
    return new Promise<void>((resolve) => {
        const animateInstance = uiItem.animate(...rest)
        animateInstance.on(AnimateEvent.COMPLETED, resolve)
    })
}
